{
/* Match! */
gint offset;
- GtkTextIter next;
GtkTextIter start_tmp;
-
+ GtkTextIter end_tmp;
+
/* Offset to start of search string */
offset = g_utf8_strlen (*win.lines, first_line_match - *win.lines);
- next = win.first_line_start;
- start_tmp = next;
+ start_tmp = win.first_line_start;
forward_chars_with_skipping (&start_tmp, offset,
visible_only, !slice, FALSE);
if (limit &&
gtk_text_iter_compare (limit, &start_tmp) > 0)
goto out; /* match was bogus */
-
+
if (match_start)
*match_start = start_tmp;
/* Go to end of search string */
- l = lines;
- while (*l)
- {
- offset += g_utf8_strlen (*l, -1);
- ++l;
- }
+ offset = 0;
+ for (l = lines; *l != NULL; l++)
+ offset += g_utf8_strlen (*l, -1);
- forward_chars_with_skipping (&next, offset,
+ end_tmp = start_tmp;
+ forward_chars_with_skipping (&end_tmp, offset,
visible_only, !slice, case_insensitive);
if (match_end)
- *match_end = next;
+ *match_end = end_tmp;
retval = TRUE;
goto out;
check_found_backward ("This is some \303\240 text", "some \303\240", 0, 8, 14, "some \303\240");
check_found_backward ("This is some \303\240 text", "\303\240 text", 0, 13, 19, "\303\240 text");
check_found_backward ("This is some \303\240 text", "some \303\240 text", 0, 8, 19, "some \303\240 text");
+
+ /* multi-byte characters outside the needle */
+ check_found_forward ("\303\200 aa", "aa", 0, 2, 4, "aa");
+ check_found_forward ("aa \303\200", "aa", 0, 0, 2, "aa");
+ check_found_backward ("\303\200 aa", "aa", 0, 2, 4, "aa");
+ check_found_backward ("aa \303\200", "aa", 0, 0, 2, "aa");
}
static void
check_found_backward ("This is some Foo\nFoo text", "foo\nfoo", flags, 13, 20, "Foo\nFoo");
check_found_backward ("This is some \303\200\n\303\200 text", "\303\240\n\303\240", flags, 13, 16, "\303\200\n\303\200");
check_found_backward ("This is some \303\200\n\303\200 text", "a\314\200\na\314\200", flags, 13, 16, "\303\200\n\303\200");
+
+ /* multi-byte characters outside the needle */
+ check_found_forward ("\303\200 aa", "aa", flags, 2, 4, "aa");
+ check_found_forward ("aa \303\200", "aa", flags, 0, 2, "aa");
+ check_found_backward ("\303\200 aa", "aa", flags, 2, 4, "aa");
+ check_found_backward ("aa \303\200", "aa", flags, 0, 2, "aa");
}
static void